package com.recharge.domain.vo;

import com.recharge.common.util.TemplateUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class CardDO implements Serializable {

    /**
     * 渠道商户号
     */
    @ApiModelProperty(value = "渠道商No")
    private String providerNo;

    /**
     * 商品编号
     */
    @ApiModelProperty(value = "商品编号")
    private Integer goodsNo;

    /**
     * 供应数量
     */
    @ApiModelProperty(value = "供应数量")
    private Integer quartity;

    /**
     * 面额
     */
    @ApiModelProperty(value = "面额")
    private Long denomination;

    /**
     * 1 移动2 电信3 联通\n
     */
    @ApiModelProperty(value = "三网类型")
    private Integer serviceProvider;

    /**
     * 1.全国 2.省 3.城市
     */
    @ApiModelProperty(value = "充值卡范围")
    private Integer regionType;

    /**
     * 省编码
     */
    @ApiModelProperty(value = "省编码")
    private String provinceCode;

    /**
     * 城市编码
     */
    @ApiModelProperty(value = "城市编码")
    private String cityCode;

    /**
     * 1.充值卡 2.油卡
     */
    @ApiModelProperty(value = "充值卡类型")
    private Integer type;

    /**
     * 供应的卡密列表
     */
    @ApiModelProperty(value = "卡列表")
    private List<CardVoucherDO> cardVoucheres;


    /**
     * 参数验证
     *
     * @return
     */
    public boolean verify() {
        if (TemplateUtils.isEmpty(providerNo)) return false;
        if (TemplateUtils.isEmpty(quartity) || quartity <= 0) return false;
        if (TemplateUtils.isEmpty(denomination))return false;
        if (serviceProvider == null || serviceProvider > 3 || serviceProvider < 1)return false;
        if (type == null || (type != 1 && type != 2))return false;
        if (cardVoucheres == null || cardVoucheres.size() == 0)return false;

        if (regionType == null){ return false;
        }else if (regionType == 2 && TemplateUtils.isEmpty(provinceCode)){ return false;
        }else if (regionType == 3){
            return !TemplateUtils.isEmpty(provinceCode) && !TemplateUtils.isEmpty(cityCode);
        }

        return true;
    }
}
